<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title>待拣货商品列表-仓库管理系统</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;top: 0px;">

    <!-- start sp-wrapper -->
    <link rel="stylesheet" href="/sb/stock.css"/>
    <div class="sp-wrapper">
        <h2 class="sp-title"><span>待拣货商品列表</span></h2>
        <div class="sp-tool">
		<span class="fl">
            <form action="/stock_out/picking_goods_list" method="get">
            <select name="locationId" style="margin-right:10px;">
				<option selected disabled>仓库</option>
				<option th:each="item:${houses}" th:value="${item.id}" th:text="${item.name}">待入库</option>

			</select>
                <!--                <select  style="margin-right:10px;">-->
                <!--				<option selected disabled>库区</option>-->
                <!--				<option>待入库</option>-->
                <!--				<option>待入库</option>-->
                <!--			</select>-->
                <input type="text" name="startDate" id="startDate" th:value="${startDate}" placeholder="开始时间"
                       class="date" autocomplete="off"> -
                    <input type="text" th:value="${endDate}" name="endDate" id="endDate" class="date" placeholder="结束时间"
                           autocomplete="off">

                <input type="text" name="orderNo" th:value="${orderNo}" placeholder="订单编号查询">
                <input type="submit" value="查询">
            </form>
        </span>
            <span class="fr">
                <i class="add" id="s-dy">生成拣货单</i>
                <!--                <i class="save" id="s-sm">扫码拣货</i>-->
            </span>
        </div>
        <div class="sp-table">
            <table>
                <thead>
                <tr>
                    <th><input type="checkbox"/></th>
                    <th>订单号</th>
                    <th>来源</th>
                    <th>商品编码</th>
                    <!--<th>商品</th>-->
                    <th>数量</th>
                    <th>仓库</th>
                    <th>库区</th>
                    <th>货架</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item:${list}">
                    <td><input type="checkbox"
                               th:if="${item.status==T(com.b2c.entity.erp.enums.StockOutFormStatusEnum).WAIT.getIndex()}"
                               class="ids" name="ids" th:value="${item.id}"/></td>
                    <td th:text="${item.sourceNo}"></td>
                    <td th:text="${T(com.b2c.entity.erp.enums.StockOutGoodsSourceEnum).getName(item.source)}"></td>
                    <td th:text="${item.specNumber}">HY19M001Q012L0001 毛衣_M</td>
                    <!--<td th:text="${item.goodsName+item.specName + item.specNumber}">HY19M001Q012L0001 毛衣_M</td>-->
                    <td th:text="${item.quantity}">2</td>
                    <td th:text="${item.locationName}">大朗总仓</td>
                    <td th:text="${item.reservoirName}">大朗总仓</td>
                    <td th:text="${item.shelfName}">大朗总仓</td>

                    <td th:text="${T(com.b2c.entity.erp.enums.StockOutFormStatusEnum).getName(item.status)}">待拣货</td>

                </tr>

                </tbody>
            </table>
        </div>
    </div>
    <script type="text/javascript" src="/sb/jquery.min.js"></script>
    <script>
        layui.use('laydate', function () {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#startDate' //指定元素
            });
            laydate.render({
                elem: '#endDate' //指定元素
            });

            // laydate.render({
            //     elem: '#startDate'
            //     ,range: true
            // });
        });

        $(function () {
            $("#s-dy").click(function () {

                var ids = [];
                $("input[name^='ids']").each(function (i, el) {
                    if ($(this).is(':checked'))
                        ids.push($(this).val());
                });
                console.log(ids);
                if (ids.length == 0)
                    alert("请选择");
                else {
                    // alert("你选择了：" + ids.join(","));
                    $.ajax({
                        url: "/ajax_stock_out/generate_picking",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json",
                        data: JSON.stringify({id: ids}),
                        success: function (res) {
                            console.log("生成拣货单");
                            console.log(res);
                            if (res.code == 0) {
                                alert("拣货单生成成功");
                                window.location.reload();
                            } else {
                                alert(res.msg);
                            }
                        }
                    });
                }

            });
        })
    </script>

</div>
</body>
<html>